/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Logger;

import javafx.data.Pair;
import javafx.io.http.HttpRequest;


/**
 * @author Hadrien
 */

public class Logger {
    init{
//        todoTask = [
//        TaskLog{taskID:0, taskName:"Buy 1 T+ Ticket"}
//        TaskLog{taskID:1, taskName:"Buy 3 RER Tickets to Auber, 2 full fare and 1 half fare, using the map"}
//        TaskLog{taskID:2, taskName:"Buy 10 T+ Tickets, reduced fare"}
//        TaskLog{taskID:3, taskName:"Buy 1 Paris Visit Ticket, for 5 days, zone 1-3, full fare"}
//        TaskLog{taskID:4, taskName:"Buy 2 ticket for Aeroport Charles de Gaulle. A friend advise you that you should take the train."}
//        TaskLog{taskID:5, taskName:"Imagine you are a tourist about 20 years old who want visit Paris and the suburbs (zone 1-3) for the week-end. Try to make the best choice in terms of prices."}
//        ];
        todoTask = [
        TaskLog{taskID:0, taskName:"Acheter 1 Ticket T+"}
        TaskLog{taskID:1, taskName:"Acheter 3 Tickets RER pour Auber, 2 pleins tarif et 1 demi tarif. Essayer d'utiliser la carte du réseau."}
        TaskLog{taskID:2, taskName:"Acheter 10 Tickets T+, demi tarif"}
        TaskLog{taskID:3, taskName:"Acheter 1 Ticket Paris Visite, pour 5 jours, zones 1-3, plein tarif"}
        TaskLog{taskID:4, taskName:"Acheter 2 tickets pour l'Aéroport Charles de Gaulle. Un ami vous conseille le RER."}
        TaskLog{taskID:5, taskName:"Imaginez que vous êtes un jeune touriste de 20 ans qui veux visiter Paris et ses environs (zones 1-3) pour le weekend. Choisissez le ticket le moins cher et le plus approprié."}
        ];
    }
    public var todoTask:TaskLog[];
    public var prenom:String;
    public var nom:String;
    public var currentTask:TaskLog;
    public var reachedTask:TaskLog[];
    public var disable:Boolean;
    public var logSender: LogSender = LogSender{};
    public function sendTask(t:TaskLog) {
        var pairs : Pair[];
        insert Pair{name:'prenom',value:prenom} into pairs;
        insert Pair{name:'nom',value:nom} into pairs;
        insert Pair{name:'task',value:t.taskID.toString()} into pairs;
        var i = 0;
        for (e in t.events) {
            insert Pair{name:'time{i}',value:e.instant} into pairs;
            insert Pair{name:'startScreen{i}',value:e.startScreen} into pairs;
            insert Pair{name:'action{i}',value:e.action} into pairs;
            insert Pair{name:'endScreen{i}',value:e.endScreen} into pairs;
            i++;
        }
        i = 0;
        for (o in t.cart.orders) {
            insert Pair{name:'ticket{i}',value:o.description} into pairs;
            i++;
        }
        if(not disable)
            logSender.SendRequest(pairs, HttpRequest.POST);
    }
    public function addEvent(startScreen:String,action:String,endScreen:String) {
        insert Events{startScreen:startScreen;action:action;endScreen:endScreen} into currentTask.events
    }


}
